import { defHttp } from '/@/utils/http/axios';
import { Modal } from 'ant-design-vue';

/**
 * 商品属性库
 */
export const listGoodsAttr = () => defHttp.get({  
  url: "/food-service/goodsAttr/list" 
})

export const saveOrUpdateGoodsAttr = (params, isUpdate) => defHttp.post({  
  url: isUpdate ? "/food-service/goodsAttr/update" : "/food-service/goodsAttr/save",
  params
})

export const deleteGoodsAttr = (params) => defHttp.delete({  
  url: "/food-service/goodsAttr/batchDelete",
  data: { ids: [ params.id ]}
}, { joinParamsToUrl: true })

export const batchDeleteGoodsAttr = (params, handleSuccess) => {
  const url = "/food-service/goodsAttr/batchDelete"
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    }
  });
}